import {reqCategoryList,reqBannerList,reqFloorsList} from '@/api'
import { Message } from 'element-ui'
const actions ={
    //获取三级分类导航列表
    async getCategoryList({commit}){
        const result =await reqCategoryList()
        if(result.code ===200){
            commit('SAVE_CATEGORYLIST',result.data)
        }else{
            Message.error(result.message)
        }
    },
    //获取轮播图
    async getBannerList({commit}){
        const result =await reqBannerList()
        if(result.code ===200){
            commit('SAVE_BANNERLIST',result.data)
        }else{
            Message.error(result.message)
        }
    },
    //floor组件轮播图
    async getFloorsList({commit}){
        const result =await reqFloorsList()
        if(result.code ===200){
            commit('SAVE_FloorsList',result.data)
        }else{
            Message.error(result.message)
        }
    },
    
}
const mutations={
    SAVE_CATEGORYLIST(state,list){
        state.categoryList = list.slice(0,15)
    },
    SAVE_BANNERLIST(state,list){
        state.bannerList= list
    },
    SAVE_FloorsList(state,list){
        state.floorsList =list
    }
}

const state = {
    categoryList:[],
    bannerList:[],
    floorsList:[]
}

const getters = {

}

export default {
    namespaced:true,
    actions,
    mutations,
    state,
    getters,
}